
CURRENT_DIR := $(shell pwd)
PROJECT_ROOT:=$(subst /app, /app,$(CURRENT_DIR))
PROJECT_ROOT:=$(word 1, $(PROJECT_ROOT))

CC  = $(CROSS_COMPILE)gcc$(CROSS_POSTFIX)
LD  = $(CROSS_COMPILE)ld$(CROSS_POSTFIX)
ELF = mktest.elf
LIB_PATH = $(PROJECT_ROOT)/build/install/lib
LIBS = -lqesf-microblaze
INCLUDES = -I$(PROJECT_ROOT)/build/install/include
ARCH_CPPFLAGS += -mlittle-endian -mcpu=v10.0 -mhard-float -ffunction-sections -fdata-sections
include $(PROJECT_ROOT)/arch/$(ARCH)/config.mk
all: compile build

OBJS = main.o uart.o

.PHONY: compile
compile:$(OBJS)
$(OBJS): %.o:%.c
	$(CC) $(CFLAGS) $(ARCH_CPPFLAGS) $(INCLUDES) -c $< -o $@

.PHONY: build
build:$(ELF)
$(ELF): $(OBJS)
	$(CC) $(CFLAGS) $(ARCH_CPPFLAGS) -o $@ $^ -L$(LIB_PATH) $(LIBS)
